import java.util.Random;
import java.util.Scanner;

/**
 * Date: 2023-04-23
 * Time: 9:58
 */

public class HelloWorld {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int guess = 0;
        Random ran = new Random();
        int number = ran.nextInt(100)+1;
        System.out.print("请输入猜的次数n:");
        int n = sc.nextInt();

        while (n!=0) {
            System.out.print("请输入你猜的数（1~100）：");
            guess = sc.nextInt();
            if(guess>number){
                System.out.println("猜错了！太大了！");
            } else if (guess<number) {
                System.out.println("猜错了！太小了！");
            }else{
                System.out.println("猜对了！真聪明！");
                System.out.println("你赢了!");
                return;
            }
            System.out.println("你还有"+(n-1)+"次机会");
            n--;
        }
        System.out.println("你输了!");
    }
}
